package cn.shentianlan.service.impl;

import cn.shentianlan.domain.dto.StudentCourseDTO;
import cn.shentianlan.mapper.StudentCourseMapper;
import cn.shentianlan.service.StudentCourseService;
import cn.shentianlan.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author 陈俊源
 * @Description TODO
 * @Date 2021/5/4
 * @Version 1.0
 */
@Service
public class StudentCourseServiceImpl implements StudentCourseService {

    @Autowired
    private StudentCourseMapper studentCourseMapper;

    @Override
    public Result save(StudentCourseDTO studentCourseDTO) {
        if (studentCourseDTO==null){
            return Result.fail("传入参数不能为空");
        }
        if (studentCourseDTO.getCourseId()==null||studentCourseDTO.getStudentId()==null){
            return Result.fail("传入数据有问题，无法执行新增操作");
        }
        studentCourseMapper.save(studentCourseDTO);
        return Result.success();
    }

    @Override
    public Result delete(StudentCourseDTO studentCourseDTO) {
        if (studentCourseDTO==null){
            return Result.fail("传入参数不能为空");
        }
        if (studentCourseDTO.getCourseId()==null||studentCourseDTO.getStudentId()==null){
            return Result.fail("传入数据有问题，无法执行删除操作");
        }
        studentCourseMapper.delete(studentCourseDTO);
        return Result.success();
    }
}
